import React from 'react';
import { Form, Field ,Button} from 'react-vant';//form是表单，Fileds是输入框Form.Item是表单的每一项
import { Toast } from 'react-vant';
export default (props) => {
  const [form] = Form.useForm();

  const onFinish = (values) => {
    console.log('form submit', values);
    if (values.username == "123" && values.password == "123") {
        window.localStorage.setItem("islogin","true")
       
       props.history.push({
            pathname:"/my"
        })
    } else {
        // Toast.fail('用户名密码错误');
        alert("登陆失败")
        window.localStorage.setItem("islogin","false")

    }
  };

  return (
    <Form onFinish={onFinish} form={form}   footer={
        <div style={{ margin: '16px 16px 0' }}>
          <Button round nativeType="submit" type="primary" block>
             登陆
          </Button>
        </div>
      }>
      <Form.Item name="username" label="用户名">
        <Field />
      </Form.Item>
      <Form.Item name="password" label="密码">
        <Field />
      </Form.Item>
    </Form>
  );
};